package es.us.lsi.daw.model.security.enums;


public enum AuthorityEnum{
	//IMPROVE Internationalization
	ROLE_ADMINISTRATOR("Administrador"),
	ROLE_ADVANCED_MANAGER("Gestor Avanzado"),
	ROLE_MANAGER("Gestor");
	
	
	private String valueString;

	private AuthorityEnum(String valueString) {
		this.valueString = valueString;
	}
	
	public AuthorityEnum getFromString(String str) {
		AuthorityEnum[] enumValues = AuthorityEnum.values();
		AuthorityEnum result=null;
		for (AuthorityEnum au : enumValues) {
			if (au.getValueString().equalsIgnoreCase(str) || getValueOf(str) != null && au.equals(getValueOf(str))) {
				result = au;
				break;
			}
		}
		return result;
	}
	
	private AuthorityEnum getValueOf(String str) {
		
		AuthorityEnum result;
		try {
			result = AuthorityEnum.valueOf(str);
		} catch (Exception e) {
			result = null;
		}
		
		return result;
	}

	public String getValueString() {
		return valueString;
	}

	public void setValueString(String valueString) {
		this.valueString = valueString;
	}

}
